package com.cupdata.zicon.jdk7concurrent.chapter1;

import java.util.concurrent.TimeUnit;

/**
 * When you call the sleep() method, Thread leaves the CPU and stops its execution for a
period of time. During this time, it's not consuming CPU time, so the CPU can be executing
other tasks.
When Thread is sleeping and is interrupted, the method throws an InterruptedException
exception immediately and doesn't wait until the sleeping time finishes.
 * @author SunYabing
 *
 */

public class FileClockTest {

	//@Test
	public static void  main(String[] args) {
		FileClock clock = new FileClock();
		Thread thread = new Thread(clock);
		thread.start();
		
		 System.out.println(Thread.currentThread().getName());
		try {
			Thread.currentThread().sleep(5000);
		} catch (InterruptedException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
        System.out.println(Thread.currentThread().getName());
//		try {
//			TimeUnit.SECONDS.sleep(5);
//		} catch (InterruptedException e) {
//			e.printStackTrace();
//		}
//		;
		
		thread.interrupt();
	}

}
